<?php
function _pr($object, $debug = 1){
    list($bactrace) = debug_backtrace();
    //print_r($bactrace);
    return my_print_r($object, $debug, $bactrace['file'], $bactrace['line']);
}

function my_print_r($object, $debug=1, $file='', $line='') {
        ob_start();
        print_r($object);
        $textObject = ob_get_contents();
        ob_end_clean();

        if($debug) {
            $rows = sizeof(explode("\n",$textObject));
            $rows = $rows > 25 ? 25 : $rows;
            $textObject = htmlspecialchars($textObject);
            $textFieldStyle = "style='width: 100%; border-width:1px; border-color : #000000; background-color : #CCCCCC; font-family: Courier;'";
            ?>
            <div style="border: 1px solid #CCCCCC; margin-bottom: 5px; paddint-top:0px;">
             <table width="100%" cellpadding="0" cellspacing="0">
             <tr><td>
             <? if($rows > 1) { ?>
             <textarea rows="<?=$rows?>" <?=$textFieldStyle?>><?=$textObject?></textarea>
             <? } else { ?>
             <input type="text" value="<?=$textObject?>" <?=$textFieldStyle?>>
             <? } ?>
             </td></tr>
             <tr><td style="font-size: 60%; font-family: Verdana; width: 100%; margin-top:0px;"><?=$file?> <?=$line?></td></tr>
             </table>
             </div>
            <?
        }

    return $textObject;

}
?>